#ifndef fuzzy_7_RULE_H_
#define fuzzy_7_RULE_H_

#include "stdint.h"
#include "mytype.h"

#ifdef __cplusplus
extern "C"
{
#endif

	typedef enum
	{
		NB7 = -3,  
		NM7 = -2,  
		NS7 = -1,  
		ZO7 = 0,  
		PS7 = 1,  
		PM7 = 2,  
		PB7 = 3,  
	} fuzzy_7_level_type;

	typedef enum
	{
		NB5 = -2,  
		NS5 = -1,  
		ZO5 = 0,  
		PS5 = 1,  
		PB5 = 2,  
	} fuzzy_5_level_type;

	typedef struct {
		float Kp_base;       
		float Ki_base;       
		float Kd_base;       
		float Kp;            
		float Ki;            
		float Kd;            
		float setpoint;      
		float prev_error;    
		float integral;      
		float dt;            
	} FuzzyPID_type;

	typedef struct {
		fuzzy_7_level_type dKp[7][7];
		fuzzy_7_level_type dKi[7][7];
		fuzzy_7_level_type dKd[7][7];
	}fuzzy_7_rule_type;

	typedef struct {
		fuzzy_5_level_type dKp[5][5];
		fuzzy_5_level_type dKi[5][5];
		fuzzy_5_level_type dKd[5][5];
	}fuzzy_5_rule_type;

	typedef struct {
		f32_rang_type e_r;
		f32_rang_type ec_r;
		f32_rang_type dkp_r;
		f32_rang_type dki_r;
		f32_rang_type dkd_r;
		const fuzzy_7_rule_type* rule;
	} fuzzy_7_obj_type;

	typedef struct {
		f32_rang_type e_r;
		f32_rang_type ec_r;
		f32_rang_type dkp_r;
		f32_rang_type dki_r;
		f32_rang_type dkd_r;
		const fuzzy_5_rule_type* rule;
	} fuzzy_5_obj_type;

	typedef struct {
		float dkp, dki, dkd;
	} fuzzy_kpid_type;

	float fuzzy_triangle_mf(float x, float a, float b, float c);

	float fuzzy_trapezoid_mf(float x, float a, float b, float c, float d);

#ifdef __cplusplus
}
#endif

#endif 
